package com.leha.api.controller;

import com.leha.core.services.ErrorMessageServices;
import com.leha.core.services.GameZZLDSServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import utils.APIResult;

import javax.ws.rs.QueryParam;

@RestController
@Api(value = "/zzl", description = "专注力大师游戏相关API")
@RequestMapping("/zzl")
@ResponseStatus(HttpStatus.OK)
public class ZZLGameController {
    @Autowired
    GameZZLDSServices zzldsServices;

    @Autowired
    private ErrorMessageServices errorMessageServices;

    @RequestMapping(value = "/question", method = {RequestMethod.GET})
    @ApiOperation(value = "获取题目", notes = "获取游戏题目")
    APIResult GetQuestion(@QueryParam(value = "uid") Integer uid) {
        return new APIResult(zzldsServices.getQuestions(1));
    }

    @RequestMapping(value = "/{questionId}/check", method = {RequestMethod.GET})
    @ApiOperation(value = "验证结果", notes = "验证选项")
    APIResult CheckAnswer(@PathVariable Integer questionId, @QueryParam(value = "choose") Integer choose) {
        return new APIResult(zzldsServices.checkQuestionAnswer(questionId, choose));
    }

    @RequestMapping(value = "/{uid}/canExchageLog", method = {RequestMethod.GET})
    @ApiOperation(value = " 可兑换的游戏记录", notes = "")
    APIResult CanExchangeGameLog(@PathVariable Integer uid) {
        return new APIResult(zzldsServices.getCanExchangeGameLog(uid));
    }
}
